// This MFC Samples source code demonstrates using MFC Microsoft Office Fluent User Interface 
// (the "Fluent UI") and is provided only as referential material to supplement the 
// Microsoft Foundation Classes Reference and related electronic documentation 
// included with the MFC C++ library software.  
// License terms to copy, use or distribute the Fluent UI are available separately.  
// To learn more about our Fluent UI licensing program, please visit 
// http://msdn.microsoft.com/officeui.
//
// Copyright (C) Microsoft Corporation
// All rights reserved.

// assitView.h : interface of the CwaiView class
//

#pragma once

#include "assitDoc.h"
class CWaiTreeNode;
#define WM_RELOADTREEDATA WM_USER+100
class CwaiView : public CScrollView
{
protected: // create from serialization only
	CwaiView();
	DECLARE_DYNCREATE(CwaiView)

// Attributes
public:
	CwaiDoc* GetDocument() const;
	CXMLDoc* getXMLDoc() { return GetDocument()->getXMLDoc();}

	void ScrollToFocusNode(CWaiTreeNode* pTreeNode);
// Operations
public:
	void reloadTreeData();
	void ClearTreeNodes();
	void buildTree(tinyxml2::XMLNode* node, CWaiTreeNode* pTreeNode);

protected:
	void reposTreeNode(CWaiTreeNode* pTreeNode, int startX, int startY);
	void layoutTree(int startX, int* startY, CWaiTreeNode* pTreeNode, std::string prefix);
	
// Overrides
public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
	virtual void OnInitialUpdate(); // called first time after construct
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

	afx_msg void OnEditChar(UINT id);
// Implementation
public:
	virtual ~CwaiView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	CWaiTreeNode* m_pTreeNode;
	CRect m_contentRect;

// Generated message map functions
protected:
	afx_msg void OnFilePrintPreview();
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
//My message handler.
	afx_msg LRESULT MyMsgHandler(WPARAM,LPARAM);
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
	virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
	virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
	afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
};

#ifndef _DEBUG  // debug version in assitView.cpp
inline CwaiDoc* CwaiView::GetDocument() const
   { return reinterpret_cast<CwaiDoc*>(m_pDocument); }
#endif

